Package PayPalAPI.api.ebay

Source Code of PayPalAPI.api.ebay.TransactionSearchResponseType

/**
* TransactionSearchResponseType.java
*
* This file was auto-generated from WSDL
* by the Apache Axis 1.2.1 Jun 14, 2005 (09:15:57 EDT) WSDL2Java emitter.
*/

package PayPalAPI.api.ebay;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.javacommerce.paypal.ws.API;
import org.javacommerce.paypal.ws.NVPConstants;

import CoreComponentTypes.apis.ebay.BasicAmountType;
import eBLBaseComponents.apis.ebay.AckCodeType;
import eBLBaseComponents.apis.ebay.PaymentTransactionSearchResultType;
import eBLBaseComponents.apis.ebay.SeverityCodeType;

public class TransactionSearchResponseType  extends eBLBaseComponents.apis.ebay.AbstractResponseType  implements NVPConstants, java.io.Serializable {
 
  private static final Log LOG = LogFactory.getLog(TransactionSearchResponseType.class.getName());
 
    /**
   *
   */
  private static final long serialVersionUID = 8309683422519030497L;
  /** Results of a Transaction Search. */
    private eBLBaseComponents.apis.ebay.PaymentTransactionSearchResultType[] paymentTransactions;

    public TransactionSearchResponseType() {
    }

    public TransactionSearchResponseType(
           eBLBaseComponents.apis.ebay.PaymentTransactionSearchResultType[] paymentTransactions) {
           this.paymentTransactions = paymentTransactions;
    }

    public TransactionSearchResponseType(InputStream _is) {
      BufferedReader reader = new BufferedReader(new InputStreamReader(_is));
      String currentLine = null;
     
      Map<String, PaymentTransactionSearchResultType> txnMap = new HashMap<String, PaymentTransactionSearchResultType>();
     
    try {
      while ((currentLine = reader.readLine()) != null) {
        String[] pairs = StringUtils.split(currentLine, "&");
        if (LOG.isDebugEnabled()) {
          LOG.debug("Read line [" + currentLine + "], split into " + pairs.length + " pairs.");
        }
        for (int i = 0; i < pairs.length; i++) {
          String[] nvp = StringUtils.split(pairs[i], "=");
          String name = nvp[0];
          String value = null;
          if (nvp.length == 2) {
            value = URLDecoder.decode(nvp[1], "UTF-8");
          }
          if (LOG.isDebugEnabled()) {
            LOG.debug("Read pair [" + name + "]/[" + value + "]");
          }
          if (isCommonField(name)) {
            processCommonField(name, value);
          }
          else if (name.startsWith(FIELD_L_TIMESTAMP)) {
            findTransaction(txnMap, FIELD_L_TIMESTAMP, name).setTimestamp(API.apiStringToCalendar(value));
          }
          else if (name.startsWith(FIELD_L_TIMEZONE)) {
            findTransaction(txnMap, FIELD_L_TIMEZONE, name).setTimezone(value);
          }
          else if (name.startsWith(FIELD_L_TYPE)) {
            findTransaction(txnMap, FIELD_L_TYPE, name).setType(value);
          }
          else if (name.startsWith(FIELD_L_EMAIL)) {
            findTransaction(txnMap, FIELD_L_EMAIL, name).setPayer(value);
          }
          else if (name.startsWith(FIELD_L_NAME)) {
            findTransaction(txnMap, FIELD_L_NAME, name).setPayerDisplayName(value);
          }
          else if (name.startsWith(FIELD_L_TRANSACTIONID)) {
            findTransaction(txnMap, FIELD_L_TRANSACTIONID, name).setTransactionID(value);
          }
          else if (name.startsWith(FIELD_L_STATUS)) {
            findTransaction(txnMap, FIELD_L_STATUS, name).setStatus(value);
          }
          else if (name.startsWith(FIELD_L_AMT)) {
            findTransaction(txnMap, FIELD_L_AMT, name).setGrossAmount(new BasicAmountType(value));
          }
          else if (name.startsWith(FIELD_L_FEEAMT)) {
            findTransaction(txnMap, FIELD_L_FEEAMT, name).setFeeAmount(new BasicAmountType(value));
          }
          else if (name.startsWith(FIELD_L_NETAMT)) {
            findTransaction(txnMap, FIELD_L_NETAMT, name).setNetAmount(new BasicAmountType(value));
          }
        }
      }
     
      ArrayList<PaymentTransactionSearchResultType> records = new ArrayList<PaymentTransactionSearchResultType>(txnMap.values());
      setPaymentTransactions((PaymentTransactionSearchResultType[]) records.toArray(new PaymentTransactionSearchResultType[records.size()]));
    } catch (Exception e) {
      if (LOG.isErrorEnabled()) {
        LOG.error("Exception caught processing response: " + e.getLocalizedMessage(), e);
      }
      setAck(AckCodeType.Failure);
      addSeverityCode("L_SEVERITYCODE0", SeverityCodeType.Error.toString());
      addErrorCode("L_ERRORCODE0", "JC1000");
      addLongMessage("L_LONGMESSAGE0", "Error processing TransactionSearch API call");
      addShortMessage("L_SHORTMESSAGE0", "Error processing request");
    }     
    }
   
    private final PaymentTransactionSearchResultType findTransaction(Map<String, PaymentTransactionSearchResultType> _txnMap, String _field, String _name) {
      String txnNum = StringUtils.replace(_name, _field, "");
      PaymentTransactionSearchResultType result = new PaymentTransactionSearchResultType();
      if (_txnMap.containsKey(txnNum)) {
        result = (PaymentTransactionSearchResultType) _txnMap.get(txnNum);
      }
      else {
        _txnMap.put(txnNum, result);
      }
      return result;
    }

    /**
     * Gets the paymentTransactions value for this TransactionSearchResponseType.
     *
     * @return paymentTransactions Results of a Transaction Search.
     */
    public eBLBaseComponents.apis.ebay.PaymentTransactionSearchResultType[] getPaymentTransactions() {
        return paymentTransactions;
    }


    /**
     * Sets the paymentTransactions value for this TransactionSearchResponseType.
     *
     * @param paymentTransactions Results of a Transaction Search.
     */
    public void setPaymentTransactions(eBLBaseComponents.apis.ebay.PaymentTransactionSearchResultType[] paymentTransactions) {
        this.paymentTransactions = paymentTransactions;
    }

    public eBLBaseComponents.apis.ebay.PaymentTransactionSearchResultType getPaymentTransactions(int i) {
        return this.paymentTransactions[i];
    }

    public void setPaymentTransactions(int i, eBLBaseComponents.apis.ebay.PaymentTransactionSearchResultType _value) {
        this.paymentTransactions[i] = _value;
    }

    private java.lang.Object __equalsCalc = null;
    public synchronized boolean equals(java.lang.Object obj) {
        if (!(obj instanceof TransactionSearchResponseType)) return false;
        TransactionSearchResponseType other = (TransactionSearchResponseType) obj;
        if (obj == null) return false;
        if (this == obj) return true;
        if (__equalsCalc != null) {
            return (__equalsCalc == obj);
        }
        __equalsCalc = obj;
        boolean _equals;
        _equals = super.equals(obj) &&
            ((this.paymentTransactions==null && other.getPaymentTransactions()==null) ||
             (this.paymentTransactions!=null &&
              java.util.Arrays.equals(this.paymentTransactions, other.getPaymentTransactions())));
        __equalsCalc = null;
        return _equals;
    }

    private boolean __hashCodeCalc = false;
    public synchronized int hashCode() {
        if (__hashCodeCalc) {
            return 0;
        }
        __hashCodeCalc = true;
        int _hashCode = super.hashCode();
        if (getPaymentTransactions() != null) {
            for (int i=0;
                 i<java.lang.reflect.Array.getLength(getPaymentTransactions());
                 i++) {
                java.lang.Object obj = java.lang.reflect.Array.get(getPaymentTransactions(), i);
                if (obj != null &&
                    !obj.getClass().isArray()) {
                    _hashCode += obj.hashCode();
                }
            }
        }
        __hashCodeCalc = false;
        return _hashCode;
    }

}
TOP

Related Classes of PayPalAPI.api.ebay.TransactionSearchResponseType

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.